/**
 * @author zhangqiang
 * @date   17/7/19
 */
import React, {Component} from 'react';
import style from './carInputItem.scss';

class InputItem extends Component {
    constructor(props) {
        super(props);
        this.state={
        }
        this.onBlurCallBack=this.onBlurCallBack.bind(this);
        this.onFocusCallBack=this.onFocusCallBack.bind(this);
    }

    //焦点离开回调
    onFocusCallBack(event){
        this.props.onFocus&&this.props.onFocus(event)
    }

    //获得焦点回调
    onBlurCallBack(event){
      this.props.onBlur&&this.props.onBlur(event)
    }

    onDeleteCallBack(){
	    this.props.onClick&&this.props.onClick()
    }
    render() {
        let creditCodeImg = this.props.creditCodeImg;

        return <div className={this.props.showUnderLine ? style.inputItem + ' ' + style.underLine : style.inputItem}>
            <div className={style.itemText} style={!this.props.showTagText?{display:'none'}:{}}>
                <span>{this.props.itemText}</span>
            </div>
            <div className={style.preFix}>粤A</div>
            <input style={!this.props.showTagText?{left:'0',padding:'0 .3rem',width: '87%'}:{}} defaultValue={this.props.defaultValue} value={this.props.value} placeholder={this.props.placeHolder}
            id={this.props.id} disabled={this.props.disabled?'disabled':''} onInput={this.props.onChange} onBlur={this.onBlurCallBack} onFocus={this.onFocusCallBack} maxLength={this.props.maxLength} type={this.props.type} className={this.props.class}/>
          {
	          creditCodeImg == 'showDelete'?<img className={style.deleteImg} src="./images/delete.png" alt="" onClick={this.props.onClick}/>:
                creditCodeImg == 'hideDelete'?'':
                  creditCodeImg == 'error'?<img className={style.deleteImg} style={{width: this.props.creditWidth}} src="./images/err.png" alt="" onClick={this.props.onClick}/>:
                    creditCodeImg == 'correct'&&!this.props.disabled? <img className={style.deleteImg} style={{width: this.props.creditWidth}} src="./images/choice.png" alt=""/>:
                    ''
          }

      </div>
    }
}

export default InputItem